<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%-- 引入页面头 --%>
<%@ include file="/pageHead.jsp"%>
<form name="form1" id="form1" action="" method="post">
	<div class="pageMain">
		<div class="pageTitle">
		<%=MessageResourcesUtils.getMessage(request, "systemmanage.resourcemanagement.title") %><span></span>
		<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.list.title") %><span></span>
		<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.list.listtitle") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %></label>
						<span>
							<input type="text" id="storecode" name="storecode" value="" />
							<input type="hidden" id="storeid" name="storeid"  >
						</span>
					</li>
					<li>
						<i></i>
						<label><%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %></label>
						<span><input type="text" id="storename" name="storename" value="" readonly="readonly" /></span>
					</li>
				</ul>
			</div>
		</div>
		<div class="button-group">			
					<input type="button" class="btn btn-default" id="butQuery" name="butQuery" value="<%=MessageResourcesUtils.getMessage(request, "common.button.query") %>" />
					<input type="button" class="btn btn-default" id="butRest" value="<%=MessageResourcesUtils.getMessage(request, "common.button.reset") %>" />
		</div>
		<table>
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>
<script type="text/javascript">
	$(document).ready(
			function() {
				
				$("#storecode").issNewMagnifier({
					title: '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.storemagnifiertitle") %>',
					url: '${systemctx}/publicMagnifier/publicMagnifier.json',
					sortName : 'modifytime',
					sortOrder : 'desc',
					linkName: 'number',
					callSqlKey: 'queryStoreMagnifierSql',
					changeIgnore: ['storecode'],
					columns: [[
							{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %>', field:'number', width:220, sortable:true, align: 'left', formel:'storecode'},
							{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %>', field:'name', width:300, sortable:true, align: 'left', formel:'storename'},
					       	{field:'id', hidden:true, formel:'storeid'}
					]],
					onBeforeOpen:function(p){
				      var queryParams = {
				    		  querystore: '%' + $('#storecode').val() + '%',
				    		  statusid: <%=SysConstant.RecordStatus.VALID %>,
				    		  state : <%=SysConstant.CommonApproveStatus.OK %>
				      };
				      return queryParams;
				    }
				});
				
				//加载分页控件 datagrid
				$('#datagrid').issdatagrid(
								{
									formid : 'form1',
									title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databasebinding.list.listtitle") %>',
									width : 'auto',
									nowrap : true,
									autoRowHeight : false,
									singleSelect : true,
									striped : true,
									url : '${systemctx}/systemmanage/databasebinding/queryDatabaseBindingListInfoDataGrid.json',
									sortName : 'modifytime',
									sortOrder : 'desc',
									idField : 'storeid',
									pagination : true,
									rownumbers : true,
									showFooter : true,
									queryParams:$('#form1').serializeObject(),
									columns : [ [ 
										{field : 'storeid',title : '<%=MessageResourcesUtils.getMessage(request, "common.button.operation") %>',width : 60,align : 'center',formatter : operate},
										{title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %>',field : 'storecode',width : 180,sortable : true,align : 'left'},
										{title : '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %>',field : 'storename',width : 180,sortable : true,align : 'left'},
										{title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databaseresource.list.ip") %>',field : 'ip',width : 100,sortable : true,align : 'left'},
									    {title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databaseresource.list.port") %>',field : 'port',width : 50,sortable : true,align : 'left'}, 
									    {title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databaseresource.list.dbname") %>',field : 'dbname',width : 100,sortable : true,align : 'left'}, 
									    {title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databaseresource.list.username") %>',field : 'dbusername',width : 100,sortable : true,align : 'left'}, 
									    {title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databaseresource.list.totalconn") %>',field : 'totalconn',width : 100,sortable : true,align : 'right'}, 
									    {title : '<%=MessageResourcesUtils.getMessage(request, "systemmanage.databaseresource.list.usedconn") %>',field : 'usedconn',width : 100,sortable : true,align : 'right'}, 
									    {field : 'dbid', hidden:true}
									    ] ],
									onLoadSuccess : function(data) {

									}
								});

						$('#butQuery').click(
								function() {
									$('#datagrid').datagrid('load',
											$('#form1').serializeObject());
								});
						
						$('#butRest').click(
								function() {
									$('#storeid').val('');
									$('#storecode').val('');
									$('#storename').val('');
						});

						function operate(val, row) {
							var url = '<a href="javascript:void(0);" class="easyui-linkbutton" onclick="binding(' + row.storeid + ',' + row.dbid + ')"><%=MessageResourcesUtils.getMessage(request, "common.button.binding") %></a>';
							return url;
						}

					});
	
	function binding(storeid,dbid) {
		$(this).isswindow({
			noheader : true,
			url : '${systemctx}/systemmanage/databasebinding/toBindingDatabaseResource.web?storeid=' + storeid + '&dbid=' + dbid
		});
	}
	
</script>
<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>